﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using 沙鹿便签.Resources;
using 沙鹿便签.Model;
using System.Diagnostics;
using System.Collections.ObjectModel;
using 沙鹿便签.Binding;
using System.Xml.Serialization;
using System.IO;
using System.Text;
namespace 沙鹿便签
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        TaskCollection tasklist = new TaskCollection();
        public MainPage()
        {
            InitializeComponent();
            listboxMainTask.ItemsSource = tasklist.Items;
            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Debug.WriteLine("Navigate to this page!!");
            if (App.QueryNewTask != null)
                tasklist.Add(App.QueryNewTask);
            App.QueryNewTask = null;
            base.OnNavigatedTo(e);
        }

        private void AppBarButton_Click(object sender, EventArgs e)
        {
            TaskStorageUtil.SaveTask(tasklist, "AppData");
        }

        private void NewTask_Click(object sender, EventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/View/AddTaskPage.xaml", UriKind.RelativeOrAbsolute));

        }

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    }
}